package org.shoppingcart.datamodel;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name="user", uniqueConstraints = {@UniqueConstraint(columnNames={"login_id"})})
public class UserAnnotated implements Serializable {

	private static final long serialVersionUID = 876966363350255135L;
	
	private int userId;
	
	private String loginId;
	
	private String password;
	
	private UserDetailsAnnotated userDetails;
	
	@Id @GeneratedValue(strategy=GenerationType.AUTO)
	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	@Column(name="login_id", nullable=false, length=25)
	public String getLoginId() {
		return loginId;
	}

	public void setLoginId(String loginId) {
		this.loginId = loginId;
	}

	@Column(name="password", nullable=false, length=40)
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	@OneToOne(cascade = CascadeType.ALL)
    @PrimaryKeyJoinColumn
	public UserDetailsAnnotated getUserDetails() {
		return this.userDetails;
	}
	
	public void setUserDetails(UserDetailsAnnotated userDetails) {
		this.userDetails = userDetails;
	}
	
}
